<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>组件中定义组件自己的数据</title>
  </head>
  <body>
    <div id="app">
      <login></login>
    </div>
    <template id="test">
      <div>
        <h1>{{ msg }}</h1>
        <ul>
          <li v-for="item,index in lists">{{ index }}、{{ item }}</li>
        </ul>
      </div>
    </template>
  </body>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    const login = {
      template: "#test",
      //使用data函数的方式定义组件的数据
      data() {
        return {
          msg: "逝水无痕",
          lists: ["java", "spring", "springboot"],
        };
      },
    };
    const app = new Vue({
      el: "#app",
      data: {},
      methods: {},
      components: {
        //注册组件
        login,
      },
    });
  </script>
</html>
